package com.example.administrator.runbook.fragments.community.model;

/**
 * Created by Administrator on 2016/11/9.
 */

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

/**
 * 评论数据
 */
public class Comment {

//    _id: "58062501a7671fd12aeaa49c",
//    tweet: "580460c16f6c3bc54e31f77b",
//    content: "呵何贺",
//    author: {
//        _id: "56aa5c7f0de4e75c653ab84d",
//                avatar: "/avatar/1f/c8/1fc8a562ddd3a8f99b0ca0f42f4bcb4d",
//                nickname: "三途川",
//                lv: 8,
//                gender: "male"
//    },
//    floor: 100,
//    tweetAuthor: "572332163cd15e74620b466a",
//    __v: 0,
//    likeCount: 0,
//    deleted: false,
//    created: "2016-10-18T13:34:57.730Z",
//    replyTo: {
//        _id: "5805fe749c8922e1766e0163",
//                floor: 90,
//                author: {
//            _id: "5730c368e815f5113e527cad",
//                    nickname: "🇼 🇴🇱🇼 🇫"
//        }
//    }

    private String _id;
    private String tweet;
    private String content;
    private String uid;
    private String avatar;
    private String nickname;
    private String lv;
    private String gender;
    private String floor;
    private String tweetAuthor;
    private String created;
    private String reId;
    private String refloor;
    private String reuid;
    private String renickname;

    public String get_id() {
        return _id;
    }

    public void set_id(String _id) {
        this._id = _id;
    }

    public String getAvatar() {
        return "http://statics.zhuishushenqi.com" + avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getCreated() {
        return created;
    }

    public void setCreated(String created) {
        this.created = created;
    }

    public String getFloor() {
        return floor;
    }

    public void setFloor(String floor) {
        this.floor = floor;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getLv() {
        return lv;
    }

    public void setLv(String lv) {
        this.lv = lv;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getRefloor() {
        return refloor;
    }

    public void setRefloor(String refloor) {
        this.refloor = refloor;
    }

    public String getReId() {
        return reId;
    }

    public void setReId(String reId) {
        this.reId = reId;
    }

    public String getRenickname() {
        return renickname;
    }

    public void setRenickname(String renickname) {
        this.renickname = renickname;
    }

    public String getReuid() {
        return reuid;
    }

    public void setReuid(String reuid) {
        this.reuid = reuid;
    }

    public String getTweet() {
        return tweet;
    }

    public void setTweet(String tweet) {
        this.tweet = tweet;
    }

    public String getTweetAuthor() {
        return tweetAuthor;
    }

    public void setTweetAuthor(String tweetAuthor) {
        this.tweetAuthor = tweetAuthor;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getData(String created) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'kk:mm:s.S'Z'", Locale.CANADA);
        Calendar date = Calendar.getInstance();
        date.setTime(format.parse(created, new ParsePosition(0)));
        Calendar now = Calendar.getInstance();
        now.setTime(new Date());

        int year = now.get(Calendar.YEAR) - date.get(Calendar.YEAR);
        int month = now.get(Calendar.MONTH) - date.get(Calendar.MONTH);
        int day = now.get(Calendar.DAY_OF_MONTH) - date.get(Calendar.DAY_OF_MONTH);

        if (year > 0) {
            return year + "年前";
        }
        if (month > 0) {
            return month + "月前";
        }
        if (day == 2) {
            return "前天";
        }
        if (day > 1) {
            return day + "天前";
        } else if (day == 1) {
            return "昨天";
        } else if (day == 0) {
            return "今天";
        }
        return "";
    }
}
